package com.ebelter.temperature.view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;

import android.view.Gravity;
import android.view.View;

import android.view.Window;
import android.view.WindowManager;

import android.widget.TextView;

import com.ebelter.btcomlib.utils.DipUtil;
import com.ebelter.temperature.R;


/**
 * desc:文本提示对话框
 */
public class TWarringModelDialog extends Dialog implements View.OnClickListener {


    private Context mContext;


    private TextView zhd_tv;
    private TextView xl_tv;
    private TextView cancel_tv;




    private void FV() {
        zhd_tv=findViewById(R.id.w_zhd_tv);
        xl_tv=findViewById(R.id.w_xl_tv);
        cancel_tv=findViewById(R.id.w_cancel_tv);
    }





    private void setListeners() {
        zhd_tv.setOnClickListener(this);
        xl_tv.setOnClickListener(this);
        cancel_tv.setOnClickListener(this);
    }

    public TWarringModelDialog(Context context) {
        super(context, R.style.dialog);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setCanceledOnTouchOutside(false);
        this.mContext = context;



    }




    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final View view = View.inflate(mContext, R.layout.twarringdialog_ly, null);

        setContentView(view);

        WindowManager.LayoutParams params = getWindow().getAttributes();
        params.gravity = Gravity.BOTTOM;
        params.width = DipUtil.getWindowWidth(getContext());
        getWindow().setAttributes(params);

        FV();
        setListeners();

    }



    private ICancelOkBtListener listener;

    public void setListener(ICancelOkBtListener listener) {
        this.listener = listener;
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.w_zhd_tv) {
            if (listener != null) {
                listener.click(this,1);
            }
        } else if (v.getId() == R.id.w_xl_tv) {
            if (listener != null) {
                listener.click(this,2);
            }
        } else if (v.getId() == R.id.w_cancel_tv) {
            if (listener != null) {
                listener.click(this,0);
            }
        }

    }

    public interface ICancelOkBtListener {
        void click(Dialog dialogView,int i);

    }


}
